package com.school.basic.controller;

import com.school.basic.entity.AreaInfo;
import com.school.basic.service.AreaInfoService;
import com.school.untils.ResultEntity;
import com.school.untils.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = "区域信息管理")
@RestController
@RequestMapping("/areaInfo")
public class AreaInfoController {
    @Autowired
    AreaInfoService areaInfoService;
    // 查询所有
    @ApiOperation("根据账号和密码查询教育局信息")
    @RequestMapping(value = "/findAreaByAccountAndPassword",method = RequestMethod.GET)
    public ResultEntity findAreaByAccountAndPassword(Integer account, String password){
        return ResultUtils.build(areaInfoService.findAreaByAccountAndPassword(account, password));
    }
    // 新增
    @ApiOperation("区域信息增加")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public ResultEntity addAreaInfo(@RequestBody AreaInfo areaInfo){
        return ResultUtils.build(areaInfoService.addAreaInfo(areaInfo));
    }

    // 查询所有
    @ApiOperation("区域信息查询所有")
    @RequestMapping(value = "/findAll",method = RequestMethod.GET)
    public ResultEntity<Object> findAll(){
        return ResultUtils.build(areaInfoService.findAll());
    }

    // 更新
    @ApiOperation("区域信息更新")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public ResultEntity updateAreaInfo(@RequestBody AreaInfo areaInfo){
        return ResultUtils.build(areaInfoService.updateAreaInfo(areaInfo));
    }

    // 区域信息状态变更
    @ApiOperation("区域信息状态变更")
    @RequestMapping(value = "/updateStatus",method = RequestMethod.POST)
    public void updateStatus(String id,Integer status){
        areaInfoService.updateStatus(id,status);
    }

    // 根据id查看详情
    @ApiOperation("区域信息查看详情")
    @GetMapping("/getDetailsById/{id}")
    public ResultEntity getDetailsById(@PathVariable("id") String id){
        return ResultUtils.build(areaInfoService.getDetailsById(id));
    }

    // 根据id删除
    @ApiOperation("区域信息信息删除")
    @DeleteMapping("/delete/{id}")
    public void deleteAreaInfo(@PathVariable("id") String id){
        areaInfoService.deleteAreaInfo(id);
    }

    // 根据id批量删除
    @ApiOperation("区域信息批量删除")
    @DeleteMapping("/batch")
    public void deleteAreaInfoList(String idList){
        areaInfoService.deleteAreaInfoList(idList);
    }

    // 根据条件分页查询
    @ApiOperation("根据条件分页查询")
    @GetMapping("/specificPage")
    public ResultEntity specificPageQueryAreaInfoList(AreaInfo areaInfo, @RequestParam int page, @RequestParam int size){
        return ResultUtils.build(areaInfoService.specificPageQueryAreaInfoList(areaInfo,page,size));
    }
}
